import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_getx/app/modules/group_info/controllers/group_info_controller.dart';
import 'package:get/get.dart';

class EditGroupNoticeDialog extends GetView<GroupInfoController>  {

  Widget buildContent() {
    return Container(
      height: 150,
      child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        children: [
          Padding(
            padding: const EdgeInsets.all(17.0),
            child: TextField(
              decoration: InputDecoration(
                labelText: "群公告: ",
                isCollapsed: true,
                contentPadding:
                EdgeInsets.symmetric(horizontal: 10, vertical: 6),
                border: OutlineInputBorder(),
              ),
              keyboardType: TextInputType.text,
              controller: controller.groupNoticeCtl,

            ),
          ),
          ElevatedButton(onPressed: () {
            if (controller.groupNoticeCtl.text.length == 0) {
              EasyLoading.showSuccess("不能为空");
              return;
            }
            controller.updateGroupNotice(controller.groupNoticeCtl.text);
          }, child: Text("确定"))
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return AlertDialog(
      contentPadding: EdgeInsets.zero,
      shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
      title: Text("编辑群聊公告"),
      content: buildContent(),
      actions: <Widget>[
        TextButton(
          onPressed: () {
            Get.back(result: false);
          },
          child: Text(
            '关闭',
            style: TextStyle(
              color: Get.theme.primaryColor,
            ),
          ),
        ),
      ],
    );
  }
}
